package com.dyna.api.domain.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.dyna.constants.DateFatter;
import com.dyna.core.utils.WebUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author zhoucaiwang
 * @date 2023/8/17
 */

@Data
public class UserLoginInfo {

    public UserLoginInfo(String username, String token, Integer loginStatus) {
        this.token = token;
        this.username = username;
        this.ipAddress = WebUtil.getIP();
        this.loginTime = LocalDateTime.now();
        this.loginStatus = loginStatus;
    }

    private String token;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "登录用户地址")
    private String ipAddress;

    @ApiModelProperty(value = "登录时间")
    @JsonFormat(pattern = DateFatter.YYYY_MM_DD_HH_MM_SS)
    @JSONField(format = DateFatter.YYYY_MM_DD_HH_MM_SS)
    private LocalDateTime loginTime;

    @ApiModelProperty(value = "登录状态")
    private Integer loginStatus;

}
